#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<unistd.h>
#include<string.h>

int main()
{
	int ssd,sd,bi;
	int port;
	struct sockaddr_in server;
	char msg[80];

	sd=socket(AF_INET,SOCK_STREAM,0);
	bzero(&server,sizeof(server));
	server.sin_family=AF_INET;
	printf("enter the port no");
	scanf("%d",&port);
	server.sin_port=htons(port);
	server.sin_addr.s_addr=INADDR_ANY;
	bi=bind(sd,(struct sockaddr*)&server,sizeof(server));
	listen(sd,1);
	int i=sizeof(server);

	ssd=accept(sd,(struct sockaddr*)&server,&i);
	while(1)
	{
		printf("\nenter the message to send\n");
		scanf("%s",msg);
		write(ssd,msg,strlen(msg));
		printf("\nmsg from client\n");
		memset(msg,'\0',sizeof(msg));
		read(ssd,msg,10);
		printf("%s",msg);
	}
	close(sd);
	close(ssd);
	return 0;
}


